package cn.shadow.aop;

import cn.shadow.aop.advisor.Advisor;
import cn.shadow.beans.BeanFactory;

import java.util.List;

/**
 * @author notto
 */
public class DefaultAopProxyFactory implements AopProxyFactory{
    @Override
    public AopProxy getAopProxy(Object object, String beanName, List<Advisor> advisorList, BeanFactory beanFactory) throws Throwable {
        if (isJdkProxy()){
            return new JdkDynamicAopProxy(beanName, object, advisorList, beanFactory);
        } else {
            return new CglibDynamicAopProxy(beanName, object, advisorList, beanFactory);
        }
    }

    private boolean isJdkProxy() {
        return true;
    }
}
